package InetAdress;
import java.io.*;
import java.net.InetAddress;
import java.net.Socket;
import java.nio.file.Files;
import java.nio.file.Paths;


public class outputAdress03 {
    public static void main(String[] args) throws IOException {
        //链接服务端IP，端口
        Socket socket = new Socket(InetAddress.getLocalHost(), 8888);
        String pathname = "d:\\xxx.png";
        BufferedInputStream bufferedInputStream=new BufferedInputStream(Files.newInputStream(Paths.get(pathname)));
        BufferedOutputStream bufferedOutputStream=new BufferedOutputStream(socket.getOutputStream());
        int n=0;
        byte[] bytes=new byte[1024];
        while ((n=bufferedInputStream.read(bytes))!=-1) {
            bufferedOutputStream.write(bytes,0,n);
        }
        socket.shutdownOutput();



        BufferedReader bufferedReader=new BufferedReader(new InputStreamReader(socket.getInputStream()));
            System.out.println(bufferedReader.readLine());
        socket.close();
        bufferedReader.close();
        bufferedInputStream.close();

       /* bufferedInputStream1.close();*/
    }
}
